package org.proddevplm.business.product;

import java.util.HashMap;
import java.util.Map;

import org.proddevplm.business.api.IAdapter;
import org.proddevplm.business.product.constants.ProductConstants;
import org.proddevplm.business.project.constants.ProjectConstants;
import org.proddevplm.helpers.ManagerUtil;

public class ProductAdapter implements IAdapter{

	@Override
	public Object adapt(int command, Map<String, Object> dataObject) {
		Object adaptedObject = null;
		Map<String, Object> productMap = new HashMap<String, Object>();
		
		switch (command){
		case ProductConstants.ADD_PRODUCT:
					
			productMap.put("productName", ManagerUtil.getStringFromReq(dataObject.get("productName")));
			System.out.println(productMap.get("productName"));
			
			productMap.put("productDescription", ManagerUtil.getStringFromReq(dataObject.get("description")));
			System.out.println(productMap.get("productDescription"));
			
			productMap.put("teamLeader", ManagerUtil.getStringFromReq(dataObject.get("projectMembers")));
			System.out.println(productMap.get("teamLeader"));
			
			productMap.put("productStartDate", ManagerUtil.getStringFromReq(dataObject.get("productStartDatePicker")));
			System.out.println(productMap.get("productStartDate"));
			
			productMap.put("productEndDate", ManagerUtil.getStringFromReq(dataObject.get("productEndDatePicker")));
			System.out.println(productMap.get("productEndDate"));
			
			adaptedObject = productMap;
			break;
		
		case ProductConstants.OPEN_PRODUCT:
			productMap.put("productId", ManagerUtil.getStringFromReq(dataObject.get("productId")));
            adaptedObject = productMap;
			break;
		
		}
		return adaptedObject;			
	}
}
